#include "RingQueue.hpp"

void* product(void* args)
{
    int data = 1;
    RingQueue<int>* bq = (RingQueue<int>*)args;
    while(true)
    {
        sleep(1);
        
        bq->Push(data);
        std::cout << "生产了一个数据：" << data << std::endl;
        data++;
    }
}

void* consum(void* args)
{
    RingQueue<int>* bq = (RingQueue<int>*)args;
    while(true)
    {
        //sleep(1);
        int data = 0;
        bq->Pop(&data);
        std::cout << "消费了一个数据：" << data << std::endl;
    }
}

int main()
{
    RingQueue<int>* bq = new RingQueue<int>();

    pthread_t producter = 0;
    pthread_create(&producter, nullptr, product, bq);

    pthread_t consumer = 0;
    pthread_create(&consumer, nullptr, consum, bq);

    pthread_join(producter, nullptr);
    pthread_join(consumer, nullptr);
    delete bq;
    return 0;
}